<@override name="body">
<div id="page-wrapper" class="gray-bg dashbard-1">
    <#include "../common/nav-header.ftl" >
    <div class="col-lg-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>修改密码</h5>
            </div>
            <div class="ibox-content">
                <form class="form-horizontal m-t " method="post" action="/admin/change_password/checkChangePassword">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">原始密码：</label>
                        <div class="col-sm-3">
                            <input  type="text" id="old_password" class="form-control"  name="old_password">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">新密码：</label>
                        <div class="col-sm-3">
                            <input  type="password" id="new_password"  class="form-control" name="new_password">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">确认密码：</label>
                        <div class="col-sm-3">
                            <input  type="password" id="new_password2"  class="form-control" name="new_password2">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-3">
                            <button class="btn btn-primary" type="submit">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <#include "../common/footer.ftl" >
</div>

<script>
    $('form').submit(function(){
        var old_password  = $('#old_password').val();
        var new_password  = $('#new_password').val();
        var new_password2 = $('#new_password2').val();
        if(new_password === ''){
            layer.msg('新密码不能为空');
            return false;
        }
        if(new_password === old_password){
            layer.msg('新密码与原始密码不能相同');
            return false;
        }
        if(new_password !== new_password2){
            layer.msg('新密码与确认密码不一致');
            return false;
        }
        var url  = $(this).attr('action');
        $.ajax({
            type:"post",
            url :url,
            data:{old_password:old_password,new_password:new_password},
            dataType: "json",
            success: function(res){
                if(res.status){
                    layer.msg(res.message,{time:1000},function(){
                        window.location.href = "/admin/login/login";
                    });
                }else{
                    layer.msg(res.message,{time:2000});
                }
            }
        });
        return false;
    });
</script>
</@override>
<@extends name="../common/common.ftl"/>